package edu.neu.cs6515.board.rules;

import edu.neu.cs6515.board.HexagonBoard;
import edu.neu.cs6515.xml.IngeniousColor;
import edu.neu.cs6515.xml.Placement;

/**
 * Validates a placement: hexagons cannot be place overlapping
 */
public final class NoneOverLappingRule extends Rule {

    private static final String REASON = "HEX-ALREADY-OCCUPIED";

    /**
     * Init class with board obj
     * 
     * @param board
     *            the board to be used for validation
     */
    public NoneOverLappingRule(final HexagonBoard board) {
        super(board);
    }

    @Override
    public boolean validate(final Placement p) {
        return (board.getHexagonAt(p.getD0(), p.getA0()).getColor() == IngeniousColor.WHITE)
                && (board.getHexagonAt(p.getD1(), p.getA1()).getColor() == IngeniousColor.WHITE);
    }

    @Override
    public String getReason() {
        return REASON;
    }

}
